/**
 * 
 */
package com.fang.www.wg.util;

import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.fang.www.wgenum.RegexGroupName;

/**
 * @author 王刚
 *
 */
public class RegexUtil {
	private String regex;
	private Pattern pattern ;
	private Matcher matcher ; 
	private String content;
	public RegexUtil(String regex,String content) {
		super();
		this.regex = regex;
		this.content = content ;
	}
	public Pattern getPattern() {
		pattern = Pattern.compile(regex);
		return pattern;
	}
	
	public void setPattern(Pattern pattern) {
		this.pattern = pattern;
	}
	
	public void setMatcher(){
		pattern = getPattern();
		matcher =pattern.matcher(content);
	}
	public Set<String> getTheMatcherContent(){
		Set<String> matcherContent = new HashSet<String>();
		setMatcher();
		while(matcher.find()){
			String content = matcher.group(RegexGroupName.URL);
			matcherContent.add(content);
		}
		return matcherContent;
	}
}
